package com.zoe.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @Author Zoe.Zhang
 * @Date: 2021/07/03
 * @Description 通过注解的方式的Filter 内部通过类的首字母决定拦截器顺序
 */
@WebFilter(filterName = "CharFilter", urlPatterns = "/*")
public class ACharFilter implements Filter {
    @Override
    public void destroy() {
    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        System.out.println("charfilter start");
        chain.doFilter(req, resp);
        System.out.println("charfilter end");
    }

    @Override
    public void init(FilterConfig config) throws ServletException {

    }

}
